﻿
    using System;
    using System.Windows;
namespace WCYCReader.Utility
{
    public class DispatcherUtility
    {
        public static void BeginInvokeOnUIThread(Action action)
        {
            if (Deployment.Current.Dispatcher.CheckAccess())
            {
                action();
                return;
            }
            Deployment.Current.Dispatcher.BeginInvoke(action);
        }

        public static void BeginInvokeOnUIThread(Delegate d, params object[] args)
        {
            if (Deployment.Current.Dispatcher.CheckAccess())
            {
                d.DynamicInvoke(args);
                return;
            }
            Deployment.Current.Dispatcher.BeginInvoke(d, args);
        }
    }
}

